package com.besttone.action;

/**
 *根据日期查询闪信用户新增和累计
 * http://localhost:9090/signalAndsms_2_solr/FlashsmsUser?day_id=20170901
 * Created by chenping on 2017/9/6.
 */
import com.besttone.bean.FlashsmsUserDayBean;
import com.besttone.model.FlashsmsUser;
import com.besttone.util.JsonUtil;
import com.jfinal.core.Controller;
import com.besttone.enums.EnumAPIResultCode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.ArrayList;
import java.util.List;
public class FlashsmsUserDayAction extends Controller{
    private static Log _log = LogFactory.getLog(FlashsmsUserDayAction.class);
    public void index() {
        //String sp_account = getPara("sp_account");
        //String sp_pwd = getPara("sp_pwd");
        String day_id=getPara("day_id");
        try {
            List<FlashsmsUserDayBean> reList = new ArrayList<FlashsmsUserDayBean>();
            FlashsmsUserDayBean UserBean = null;
            List<FlashsmsUser> buttonList = FlashsmsUser.dao.getCntsByDay(day_id);
            for (FlashsmsUser button : buttonList) {
                UserBean = new FlashsmsUserDayBean();
                UserBean.setBusi_type(button.getStr("busi_type"));
                UserBean.setIncrease_user(button.getInt("increase_user"));
                UserBean.setTotal_user(button.getInt("total_user"));
                UserBean.setDay_id(button.getStr("day_id"));
                reList.add(UserBean);
            }
            String str = JsonUtil.ObjectToJsonString(reList);
            System.out.println(str);
            setAttr("result_msg", str);
        }catch (Exception e) {
            _log.info("solr查询异常:" + e);
            setAttr("result_code", EnumAPIResultCode.SYSTEM_ERROR.getValue());
            setAttr("result_msg", EnumAPIResultCode.SYSTEM_ERROR.getName());
        }
        renderJson();
        return;
    }
}
